package cn.ruc.dbiir.storm.generator.util;

import java.io.FileWriter;
import java.io.IOException;

public class FileWriterUtil {

	/**
	 * file Op [open]
	 * author：mark   
	 * createTime：Jun 4, 2018 9:36:53 PM
	 */
	public static FileWriter initialFileWriter(FileWriter fw,String path,Boolean isAppend) {
		try {
			fw = new FileWriter(path,isAppend);
		} catch (IOException e) {
			e.printStackTrace();
		}  
		return fw;
	}
	
	/**
	 * file Op [inset]
	 * author：mark   
	 * createTime：Jun 4, 2018 9:37:12 PM
	 * @param content
	 */
	public static void insertToFile(FileWriter fw,String content){
		try {
			fw.write(content);  
			fw.flush();
		} catch (IOException e) {
			e.printStackTrace();
		} 
	}
	
	/**
	 * file Op [close]
	 * author：mark   
	 * createTime：Jun 4, 2018 9:37:38 PM
	 */
	public static void closeFileWriter(FileWriter fw) {
		try {
			fw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
}
